package lock.runnable;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;

/**
 * @author jiangwz
 * @create 2019/7/10.
 */
public class TestRun1 implements Runnable{

    private AtomicInteger age = new AtomicInteger(1);//原子性，所以不会出错

    private ReentrantLock lock = new ReentrantLock();

    @Override
    public /*synchronized*/ void run() {
        System.out.println("age = " + age.getAndIncrement());
    }

    public static void main(String[] args) {
        TestRun1 t = new TestRun1();
        for (int i = 0; i < 100; i++) {
            new Thread(() -> t.run()).start();
        }
    }
}
